<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Unicode 解码工具</title>
    <link rel="icon" type="image/svg+xml" href="favicon.svg">
    <link rel="stylesheet" href="common.css">
    <link rel="stylesheet" href="paste-button.css">
    <script>
        // 防止主题闪烁 - 在页面渲染前应用主题
        (function() {
            const theme = localStorage.getItem('global-theme') || 'dark';
            if (theme === 'dark') {
                document.documentElement.classList.add('dark-theme');
            }
        })();
    </script>
</head>
<body>
    <div style="display: flex; height: 100vh;">
        <div class="sidebar">
            <div class="sidebar-header">
                <h2>工具库</h2>
                <button class="theme-toggle-btn" id="globalThemeToggle" title="切换主题" aria-label="切换浅色/深色主题">
                    <span class="theme-icon">🌓</span>
                </button>
            </div>
            <div class="sidebar-item" onclick="location.href='index.html'">JSON 格式化</div>
            <div class="sidebar-item" onclick="location.href='json-comparator.html'">JSON 对比</div>
            <div class="sidebar-item" onclick="location.href='text-comparator.html'">文本对比</div>
            <div class="sidebar-item" onclick="location.href='url-codec.html'">URL 编解码</div>
            <div class="sidebar-item active" onclick="location.href='text-decoder.html'">文本解码</div>
            <div class="sidebar-item" onclick="location.href='datetime-converter.html'">日期时间转换</div>
            <div class="sidebar-item" onclick="location.href='md5-hash.html'">加解密</div>
            <div class="sidebar-item" onclick="location.href='ck-extractor.html'">CK 提取</div>
            <div style="margin-top: auto; padding: 15px 20px; font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--border-color); text-align: center;">
                版本: v1.0.1
            </div>
        </div>
        <div class="main-content">
            <div class="simple-panel">
                <h2>Unicode 解码工具</h2>

                <div class="input-group">
                    <label>输入 Unicode 编码文本 (如: \u4e2d\u6587)</label>
                    <textarea id="decode-input" placeholder="输入 Unicode 转义序列，如: \u4e2d\u6587"></textarea>
                </div>

                <div class="button-group">
                    <button onclick="decodeText()">解码</button>
                    <button onclick="copyDecodeResult()">复制结果</button>
                    <button class="btn-paste" id="pasteDecodeBtn" title="从剪贴板粘贴">粘贴</button>
                    <button class="secondary" onclick="clearDecoder()">清空</button>
                </div>

                <div class="message" id="decode-message"></div>

                <div class="input-group">
                    <label>解码结果</label>
                    <textarea id="decode-output" placeholder="解码结果将显示在这里..." readonly></textarea>
                </div>
            </div>
        </div>
    </div>
    <script src="theme-toggle.js"></script>
    <script src="paste-button.js"></script>
    <script src="text-decoder.js"></script>
    <script>
        // 初始化粘贴按钮
        document.addEventListener('DOMContentLoaded', () => {
            const pasteBtn = document.getElementById('pasteDecodeBtn');
            if (pasteBtn) {
                pasteBtn.addEventListener('click', async () => {
                    await PasteButton.paste('decode-input');
                });
            }
        });
    </script>
</body>
</html>
